<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>19_2D-位移-水平垂直居中</title>
        <style>
            * {
                margin: 0;
                padding: 0;
            }

            .outer {
                position: relative;
                width: 500px;
                height: 400px;
                border: 1px solid black;
            }

            .inner {
                /* position: absolute;
                left: 0;
                right: 0;
                bottom: 0;
                top: 0;
                margin: auto; */



                width: 200px;
                height: 200px;
                background-color: aqua;

           
                position: absolute;
                left: 50%;
                top: 50%;
                transform: translate(-50%,-50%);


            }
        </style>
    </head>
    <body>
        <div class="outer">
            <div class="inner"></div>
        </div>



    </body>
</html>